﻿/*
 * ©2009-2010 XELF
 * http://xelf.info
 */

#if XNA || WINDOWS_PHONE
using Microsoft.Xna.Framework;
#endif

namespace XELF.Framework {

#if XNA || WINDOWS_PHONE
	public static partial class Vector2Helper {
#else
	public partial struct Vector2 {
#endif
		/// <summary>
		/// 要素別の積和(m * a + b)
		/// </summary>
		/// <param name="m"></param>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Madd(ref Vector2 m, ref Vector2 a, ref Vector2 b, out Vector2 result) {
			result = new Vector2(m.X * a.X + b.X, m.Y * a.Y + b.Y);
		}

		/// <summary>
		/// 要素別の積和(m * scale + b)
		/// </summary>
		/// <param name="m"></param>
		/// <param name="scale"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Madd(ref Vector2 m, float scale, ref Vector2 b, out Vector2 result) {
			result = new Vector2(m.X * scale + b.X, m.Y * scale + b.Y);
		}
	}

#if XNA || WINDOWS_PHONE
	public static partial class Vector3Helper {
#else
	public partial struct Vector3 {
#endif
		/// <summary>
		/// 要素別の積和(m * a + b)
		/// </summary>
		/// <param name="m"></param>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Madd(ref Vector3 m, ref Vector3 a, ref Vector3 b, out Vector3 result) {
			result = new Vector3(m.X * a.X + b.X, m.Y * a.Y + b.Y, m.Z * a.Z + b.Z);
		}

		/// <summary>
		/// 要素別の積和(m * scale + b)
		/// </summary>
		/// <param name="m"></param>
		/// <param name="scale"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Madd(ref Vector3 m, float scale, ref Vector3 b, out Vector3 result) {
			result = new Vector3(m.X * scale + b.X, m.Y * scale + b.Y, m.Z * scale + b.Z);
		}
	}

#if XNA || WINDOWS_PHONE
	public static partial class Vector4Helper {
#else
	public partial struct Vector4 {
#endif
		/// <summary>
		/// 要素別の積和(m * a + b)
		/// </summary>
		/// <param name="m"></param>
		/// <param name="a"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Madd(ref Vector4 m, ref Vector4 a, ref Vector4 b, out Vector4 result) {
			result = new Vector4(m.X * a.X + b.X, m.Y * a.Y + b.Y, m.Z * a.Z + b.Z, m.W * a.W + b.W);
		}

		/// <summary>
		/// 要素別の積和(m * scale + b)
		/// </summary>
		/// <param name="m"></param>
		/// <param name="scale"></param>
		/// <param name="b"></param>
		/// <param name="result"></param>
		public static void Madd(ref Vector4 m, float scale, ref Vector4 b, out Vector4 result) {
			result = new Vector4(m.X * scale + b.X, m.Y * scale + b.Y, m.Z * scale + b.Z, m.W * scale + b.W);
		}
	}

}
